load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_test")

DEPENDENCIES = [
    # Keep sorted.
    "//rs/crypto/utils/threshold_sig",
    "//rs/crypto/utils/threshold_sig_der",
    "//rs/monitoring/metrics",
    "//rs/protobuf",
    "//rs/recovery",
    "//rs/registry/routing_table",
    "//rs/registry/subnet_type",
    "//rs/replay",
    "//rs/state_manager",
    "//rs/state_tool:state_tool_lib",
    "//rs/types/base_types",
    "//rs/types/types",
    "@crate_index//:clap",
    "@crate_index//:hex",
    "@crate_index//:ic-agent",
    "@crate_index//:serde",
    "@crate_index//:serde_cbor",
    "@crate_index//:slog",
    "@crate_index//:strum",
    "@crate_index//:url",
]

DEV_DEPENDENCIES = [
    # Keep sorted.
    "//rs/test_utilities/tmpdir",
]

MACRO_DEPENDENCIES = [
    # Keep sorted.
    "@crate_index//:strum_macros",
]

ALIASES = {}

rust_library(
    name = "subnet_splitting",
    srcs = glob(
        ["src/**/*.rs"],
        exclude = ["src/main.rs"],
    ),
    aliases = ALIASES,
    crate_name = "ic_subnet_splitting",
    proc_macro_deps = MACRO_DEPENDENCIES,
    version = "0.1.0",
    visibility = ["//rs:system-tests-pkg"],
    deps = DEPENDENCIES,
)

rust_binary(
    name = "subnet-splitting-tool",
    srcs = ["src/main.rs"],
    aliases = ALIASES,
    proc_macro_deps = MACRO_DEPENDENCIES,
    visibility = ["//rs:release-pkg"],
    deps = DEPENDENCIES + [
        ":subnet_splitting",
        "//rs/canister_sandbox:backend_lib",
    ],
)

rust_test(
    name = "subnet_splitting_tool_test",
    compile_data = ["test_data/fake_expected_manifests.data"],
    crate = "subnet_splitting",
    deps = DEPENDENCIES + DEV_DEPENDENCIES,
)
